package com.aftvc.springbootstartdemo.controller;


import cn.hutool.core.util.StrUtil;
import com.aftvc.springbootstartdemo.pojo.ActCardResult;
import com.aftvc.springbootstartdemo.service.ActCardResultService;
import com.aftvc.springbootstartdemo.utils.DatabaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YH
 * @since 2022-08-11
 */
@RestController
@RequestMapping("/actCardResult")
public class ActCardResultController {

    @Autowired
    private ActCardResultService actCardResultService;
    /**
     * 获取表字段和类型信息
     * @return
     */
    @GetMapping("/allColumn")
    public List<Map<String, Object>> getColumnNames(){
        List<Map<String, Object>> list = actCardResultService.getColumnNames();
        return list;
    }

    /**
     * 获取查询信息
     * @param list
     * @return
     */
    @PostMapping("/getSelectInfo")
    public List<ActCardResult> getSelectInfo(@RequestBody List<String> list){
        StringBuilder sb = new StringBuilder();
        for (String s : list) {
            sb=sb.append(s);
        }
        System.out.println(sb.toString());
        List<ActCardResult> selectInfo=null;
        try {
            selectInfo = actCardResultService.getSelectInfo(sb.toString());
        } catch (Exception e) {
            System.out.println("参数存在问题请检查后再次查询！");
            e.printStackTrace();
        }
        return selectInfo;
    }
}

